package gui;

import java.io.File;

/**
 * @author Ramy Refky 
 * */
public class ModuleComponentGraphics extends ComponentGraphics{

	private static final long serialVersionUID = 1L;
	
	File moduleFile;
	boolean showDetails;
	
	/**
	 * Constructor initializes MODULE Gate by initializing ComponentGraphics, and then painting the ModuleComponentLabel.
	 * A loadHandler instance is used to set the input and output ComponentPins accordingly. 
	 * @param MainGui, XLocation, YLocation, Width, Height, InputFile, ShowDetails
	 * */
	public ModuleComponentGraphics(MainGui mg,int originalXLoc,int originalYLoc,
			int originalWidth,int originalHeight,File moduleFile,boolean showDetails){
		super(mg,originalXLoc,originalYLoc,originalWidth,originalHeight);
		
		this.moduleFile=moduleFile;
		this.showDetails=showDetails;
		LoadDataHandler ld = new LoadDataHandler(mg,moduleFile);
		 
		numOfInputs=ld.getLoadedModuleInputs();
		numOfOutputs=ld.getLoadedModuleOutputs();
		
		setInputPins(numOfInputs);
		setOutputPins(numOfOutputs);
		if(moduleFile!=null){
			this.remove(compLabel);
			compLabel=new ModuleComponentLabel(newXLoc,newYLoc,originalWidth,originalHeight,ld,moduleFile.getName(),showDetails);
			this.add(compLabel);
			setComponentZOrder(compLabel,0);
		}
		repaint();
	}
	/**
	 * Gets the File to be imported as a module.
	 * @return File
	 * */
	public File getFile(){
		return moduleFile;
	}
	/**
	 * Gets the boolean value that toggles between displaying or hiding details of the MODULE Gate.
	 * @return boolean
	 * */
	public boolean getShowDetailsValue(){
		return showDetails;
	}
}